//
//  ViewController.m
//  Animation_UIview1
//
//  Created by 刘文超 on 2019/12/24.
//  Copyright © 2019 刘文超. All rights reserved.
//

#import "ViewController.h"
#import "An_uiviewViewController.h"
#import "An_uiviewBlockViewController.h"
#import "An_CaViewController.h"
#import "An_PopViewController.h"
@interface ViewController ()
@property(nonatomic,strong)NSArray *dataArray;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"动画学习";
    
    self.dataArray = @[@{@"head":@"UIview 动画",@"desc":@"实质就是对CA的封装，系统提供了一些API",@"arr":@[@"UIview 类方法动画",@"UIview Block 动画"]},@{@"head":@"CA 动画",@"desc":@"核心动画作用在layer上，不能响应触摸事件",@"arr":@[@"CABasicAnimation",@"CAKeyframeAnimation",@"CATransition",@"CASpringAnimation"]},@{@"head":@"facebook pop 动画",@"desc":@"是谷歌推出的一个动画扩展引擎，通过cocopods 可以导入",@"arr":@[@"POPSpringAnimation (弹簧效果)",@"POPDecayAnimation (衰减效果)",@"POPBasicAnimation (基本动画)",@"POPAnimatableProperty (自定义属性动画)"]},@{@"head":@"其他 动画",@"arr":@[@"",@""]}];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.dataArray[section][@"arr"] count];
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}
//-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
//{
//   NSString *str = self.dataArray[section][@"head"];
//    return str;
//}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 40;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return [UIView new];
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor colorWithRed:(CGFloat)235/255.0f green:(CGFloat)235/255.0f blue:(CGFloat)235/255.0f alpha:1];
    UILabel *leftLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, 0, [UIScreen mainScreen].bounds.size.width, 40)];
    [view addSubview:leftLabel];
    leftLabel.font=[UIFont systemFontOfSize:14];
    NSString *str = self.dataArray[section][@"head"];
    leftLabel.text=str;
    leftLabel.backgroundColor=[UIColor clearColor];
    
    return view;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.dataArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static  NSString *cellID=@"cell";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    NSString *str = self.dataArray[indexPath.section][@"arr"][indexPath.row];
    cell.textLabel.text = str;
    return cell;
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
      NSString *str = self.dataArray[indexPath.section][@"arr"][indexPath.row];
    if (indexPath.section == 0 && indexPath.row == 0) {
        An_uiviewViewController *VC =[An_uiviewViewController new];
        VC.title = str;
        [self.navigationController pushViewController:VC animated:YES];
    }else if (indexPath.section == 0 && indexPath.row == 1){
        An_uiviewBlockViewController *VC =[An_uiviewBlockViewController new];
        VC.title = str;
        [self.navigationController pushViewController:VC animated:YES];
    }else if (indexPath.section == 1 && indexPath.row == 0){
        An_CaViewController *VC =[An_CaViewController new];
        VC.type = ANmiationStyle_cabase;
        VC.title = str;
        [self.navigationController pushViewController:VC animated:YES];
    }else if (indexPath.section == 1 && indexPath.row == 1){
        An_CaViewController *VC =[An_CaViewController new];
        VC.type = ANmiationStyle_transi;
        VC.title = str;
        [self.navigationController pushViewController:VC animated:YES];
    }else if (indexPath.section == 1 && indexPath.row == 2){
        An_CaViewController *VC =[An_CaViewController new];
        VC.type = ANmiationStyle_transi;
        VC.title = str;
        [self.navigationController pushViewController:VC animated:YES];
    }else if (indexPath.section == 1 && indexPath.row == 3){
        An_CaViewController *VC =[An_CaViewController new];
        VC.type = ANmiationStyle_sprin;
        VC.title = str;
        [self.navigationController pushViewController:VC animated:YES];
    }else if (indexPath.section == 2 && indexPath.row == 0){
        An_PopViewController *VC = [An_PopViewController new];
        VC.type = AnpopStyle_tanhuang;
        VC.title = str;
        [self.navigationController pushViewController:VC animated:YES];
    }else if (indexPath.section == 2 && indexPath.row == 1){
        An_PopViewController *VC = [An_PopViewController new];
        VC.type = AnpopStyle_shuaitui;
        VC.title = str;
        [self.navigationController pushViewController:VC animated:YES];
    }else if (indexPath.section == 2 && indexPath.row == 2){
        An_PopViewController *VC = [An_PopViewController new];
        VC.type = AnpopStyle_jichu;
        VC.title = str;
        [self.navigationController pushViewController:VC animated:YES];
    }else if (indexPath.section == 2 && indexPath.row == 3){
        An_PopViewController *VC = [An_PopViewController new];
        VC.type = AnpopStyle_zidingyi;
        VC.title = str;
        [self.navigationController pushViewController:VC animated:YES];
    }
}
@end
